﻿using B.S.BasicData.ErrorCode;
using B.S.BasicData.Infrastructure.Interfance;
using B.S.BasicData.Read.Apilication.Common.Province;
using B.S.BasicData.Read.DTOS;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class ProvinceController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<ProvinceController> logger;

        public ProvinceController(IMediator mediator,ILogger<ProvinceController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 树形
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<ProvinceDTO>>> GetprovinceHandle([FromQuery]GetprovinceCommon request)
        {
            try
            {
                logger.LogInformation("树形结构查询成功");
                return mediator.Send(request);
            }
            catch (Exception ex)
            {
                logger.LogError("树形结构查询异常"+ex.Message);
                throw;
            }
          
        }


        }
}
